<template>
	<publicPage>
		<view class="bgf">
			<view class="linh-44 px-14"><text class="colorRED">*</text>1. 请上传你的舌苔</view>
			<view class="borderT px-14 pt-10 pb-5 fz-14">
				<Upload
					:maxSize="30"
					:modelValue.sync="imgs1"
					bottomTips="只支持.jpg、.png、.jpeg格式，不超过30M"
				/>
			</view>
		</view>
		<view class="bgf mt-10">
			<view class="linh-44 px-14"><text class="colorRED">*</text>2. 请上传你的面相</view>
			<view class="borderT px-14 pt-10 pb-5 fz-14">
				<Upload
					:maxSize="30"
					:modelValue.sync="imgs2"
					bottomTips="只支持.jpg、.png、.jpeg格式，不超过30M"
				/>
			</view>
		</view>

		<view class="px-15 py-15 fexdBtn">
			<u-button
				type="primary"
				text="确认提交"
				:customStyle="{
					fontSize: '32rpx',
					borderRadius: '20rpx',
					height: '88rpx',
				}"
				:throttleTime="500"
				@click="submit"
			></u-button>
		</view>

		<u-popup :show="showPrivacy" mode="bottom" :round="10" :safeAreaInsetBottom="false">
			<view class="px-20">
				<view class="tc fw-7 fz-15 py-10" style="letter-spacing: 2rpx">温馨提示</view>
				<view class="py-10" style="letter-spacing: 2rpx"
					>检测到您暂未登录，请点击下方立即登录按钮后允许授权手机号，即可使用该功能。</view
				>
				<view class="disFlxJS pt-20 pb-30">
					<u-button
						type="primary"
						text="立即登录"
						:customStyle="{
							fontSize: '32rpx',
							borderRadius: '20rpx',
							height: '88rpx',
						}"
						open-type="getPhoneNumber"
						@getphonenumber="getPhoneNumber"
					></u-button>
				</view>
			</view>
		</u-popup>
	</publicPage>
</template>

<script>
import Upload from "@/components/upload.vue";
export default {
	components: {
		Upload,
	},
	data() {
		return {
      exp_id: "", // 专家ID
			imgs1: "",
			imgs2: "",
			showPrivacy: false,
		};
	},
	methods: {
		// 立即登录
		getPhoneNumber(e) {
			this.$store.dispatch("getPhoneNumber", e).then(() => {
				this.showPrivacy = false;
			});
		},
    // 确认提交
    submit() {
      const that = this
      if(!that.imgs1 || !that.imgs2){
        uni.showToast({
          title: `请上传舌苔和面相`,
          icon: 'none'
        })
        return
      }
      // 发送已上传图片
      that.$store.dispatch("sendCustomMessage",{
        type: 'uploadPictures',
        toID: that.exp_id,
        title: '上传图片',
        tongue: that.imgs1,
        face: that.imgs2
      });
      uni.showToast({title: `提交成功`});
      that.goBack()
    }
	},
  onLoad(options){
    const that = this
    if(options.scene){
      // 扫码进入
      that.exp_id = options.scene
    }
  },
	onShow() {
		if (!this.isLogin) {
			// 未登录
			setTimeout(() => {
				this.showPrivacy = true;
			}, 100);
		}
	},
};
</script>

<style lang="scss" scoped>
.colorRED {
	color: red;
}
.fexdBtn {
	position: fixed;
	left: 0;
	width: 100%;
	bottom: 0;
	bottom: constant(safe-area-inset-bottom);
	bottom: env(safe-area-inset-bottom);
}
</style>
